
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projekt;

/**
 *
 * @author linuslofberg
 */
public class PickUp {

    private int prevArmor = 0;
    private int prevWeapon = 0;
    private Dungeon dg;

    public PickUp(Dungeon dgx) {
        dg = dgx;
    }

    public void PickUpItem(Items i, Hero h, Level l) {
        Sound player = new Sound();
        if (i.getClass() == Armor.class) {
            if (i.getExtraArmor() > prevArmor) {
                h.setArmor(h.getArmor() + i.getExtraArmor() - prevArmor);
                prevArmor = i.getExtraArmor();
                dg.getGui().addEventItem(i, h, String.valueOf(i.getExtraArmor()), " ", " ", 2);
                player.playwav("hammer.wav");
            }
        } else if (i.getClass() == Gold.class) {
            h.setGold(h.getGold() + i.getExtraGold());
            dg.getGui().addEventItem(i, h, String.valueOf(i.getExtraGold()), " ", " ", 5);
            player.playwav("coins.wav");
        } else if (i.getClass() == Potions.class) {
                h.setHp(100);
                dg.getGui().addEventItem(i, h, String.valueOf(i.getExtraHp()), " ", " ", 3);
                player.playwav("heartbeats.wav");
           
        } else if (i.getClass() == Ring.class) {
            h.setArmor(h.getArmor() + i.getExtraArmor());
            h.setHp(h.getHp() + i.getExtraHp());
            h.setAttackDmg(h.getAttackDmg() + i.getExtraAttackDmg());
            dg.getGui().addEventItem(i, h, String.valueOf(i.getExtraAttackDmg()), String.valueOf(i.getExtraArmor()), String.valueOf(i.getExtraHp()), prevArmor);
            player.playwav("coin_flip.wav");
        } else if (i.getClass() == Weapon.class) {
            if (i.getExtraAttackDmg() > prevWeapon) {
                h.setAttackDmg(h.getAttackDmg() + i.getExtraAttackDmg() - prevWeapon);
                prevWeapon = i.getExtraAttackDmg();
                dg.getGui().addEventItem(i, h, String.valueOf(i.getExtraAttackDmg()), " ", " ", 1);
                player.playwav("knife.wav");
            }
        }

        l.addLevelObject(i.getArrayX(), i.getArrayY(), new Floor());
    }
}
